package org.anyin.gitee.shiro.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.anyin.gitee.shiro.base.BusinessCodeEnum;
import org.anyin.gitee.shiro.model.UserInfo;
import org.anyin.gitee.shiro.service.IUserInfoService;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UserInfoServiceImpl implements IUserInfoService {

    private static final String DEFAULT_USERNAME = "anyin";

    @Override
    public UserInfo findByUsername(String username) {
        // 从数据库查询用户信息
        if(DEFAULT_USERNAME.equals(username)){
            UserInfo userInfo = new UserInfo();
            userInfo.setId(1);
            userInfo.setNickName("暗音");
            userInfo.setUsername("anyin");
            userInfo.setPassword("123456");
            return userInfo;
        }
        throw  BusinessCodeEnum.USER_NOT_FOUND.getException();
    }
}
